﻿<cmn:UserControlBase x:Class="Hopscotch.Presentation.Controls.Core.PriceControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 	
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:cmn="clr-namespace:Hopscotch.Presentation.Common;assembly=Hopscotch.Presentation.Common"
             xmlns:cmnCnvrtrs="clr-namespace:Hopscotch.Presentation.Common.Converters;assembly=Hopscotch.Presentation.Common"
             
             x:Name="PriceUserControl"			 
             mc:Ignorable="d" 
             d:DesignHeight="25" d:DesignWidth="300">

    <cmn:UserControlBase.Resources>
        <ResourceDictionary Source="../Resources/ErrorContentControl.xaml" />
    </cmn:UserControlBase.Resources>

            <Grid>

        <Grid.RowDefinitions>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <ContentControl Template="{StaticResource ErrorContentControl}" IsTabStop="False">
            <xctk:DoubleUpDown Name="PriceTextBox"
                                   Background="{Binding Path=Background, ElementName=PriceUserControl}"
                                   TextAlignment="Left"
                                   Increment="{Binding Path=Increment, ElementName=PriceUserControl}"
                                   Validation.ErrorTemplate="{x:Null}"
                                   BorderThickness="0">
                <xctk:DoubleUpDown.Value>
                    <Binding Path="Price" ElementName="PriceUserControl" 
                                        Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" 
                            
                                        NotifyOnValidationError="False"
                                        ValidatesOnExceptions="True" 
                                        ValidatesOnDataErrors="True" 
                                        ValidatesOnNotifyDataErrors="True">
                    </Binding>
                </xctk:DoubleUpDown.Value>
            </xctk:DoubleUpDown>
        </ContentControl>
        
        <ComboBox Grid.Column="1" 
                  Name="CurrencyComboBox"
                  IsSynchronizedWithCurrentItem="True"
                  DisplayMemberPath="Code"
                  Style="{StaticResource ResourceKey=ControlErrorToolTipStyle}">

            <ComboBox.SelectedItem>
                <Binding Path="Currency" ElementName="PriceUserControl" Mode="TwoWay"
                         NotifyOnValidationError="False"
                         ValidatesOnExceptions="True" 
                         ValidatesOnDataErrors="True" 
                         ValidatesOnNotifyDataErrors="True">
                </Binding>
            </ComboBox.SelectedItem>
            <ComboBox.ItemsSource>
                <Binding Path="Currencies"
                         ElementName="PriceUserControl"
                         NotifyOnValidationError="False"
                         ValidatesOnExceptions="True"
                         ValidatesOnDataErrors="False"
                         ValidatesOnNotifyDataErrors="False">
                </Binding>
            </ComboBox.ItemsSource>
        </ComboBox>

    </Grid>
</cmn:UserControlBase>
